const util = require('../../../utils/util.js')
const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter
const oss_domain = getApp().globalData.oss_domain
const today = util.formatDate(new Date())


// pages/rank_wrong_index/rank_wrong_index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    icon_url:oss_domain + 'static/picture/app_icon/',
    loading:true,
  },

  page_init(jg_stu_id){
    wx.showLoading({
      title: '大数据计算中……',
    })
    wx.request({
      url: domainName + '/rank_mine_index_init',
      data: {
        jg_stu_id,
      },...parameter,
      success: res => {
        wx.hideLoading()
        // console.log('res',res.data)
        this.setData({
          stu_info:res.data.stu_info,
          rank_list:res.data.rank_list,
          loading:false,
        })
      },
    })
  },



  tap_item(e){
    getApp().get_vibration()
    let index = e.currentTarget.id
    console.log(index)
    if(index=='今日测试'){ // 今日测试
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/transcript_list/transcript_list?jg_stu_id=' + this.jg_stu_id + '&stu_name=' + this.data.stu_info.stu_name + '&test_type=&date_set=' + today,
      })
    }else if(index=='今日错题'){ // 今日错题
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/wrongs_ofStu/wrongs_ofStu?jg_stu_id=' + this.jg_stu_id + '&date_set=' + today + '&stu_name=' + this.data.stu_info.stu_name
      })
    }else if(index=='今日题量'){ // 今日题量
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/do_records/do_records?jg_stu_id=' + this.jg_stu_id + '&date_set=' + today
      })
    }else if(index=='累计测试'){ // 累计测试
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/transcript_list/transcript_list?jg_stu_id=' + this.jg_stu_id + '&stu_name=' + this.data.stu_info.stu_name + '&test_type=&date_set=',
      })
    }else if(index=='累计错题'){ // 累计错题
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/wrongs_ofStu/wrongs_ofStu?jg_stu_id=' + this.jg_stu_id + '&date_set=' + '&stu_name=' + this.data.stu_info.stu_name
      })
    }else if(index=='累计题量'){ // 累计题量
      getApp().get_vibration()
      wx.navigateTo({
        url: '/pages/doTi/do_records/do_records?jg_stu_id=' + this.jg_stu_id + '&date_set='
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('options',options)
    this.jg_stu_id = options.jg_stu_id
    this.page_init(this.jg_stu_id)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.setData({
      windowHeight:wx.getSystemInfoSync().windowHeight
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },


  /**
   * 用户点击右上角分享
   */
  onShareAppMessage(e) {
    return  {
      // title: '试卷：' + test_name,
      // imageUrl:'https://yqwl.top/app_images/caac.png',
      path:'/pages/rank_mine_index/rank_mine_index?jg_stu_id=' + this.jg_stu_id
    }
  }
})